package com.slashvision.im.chat

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import com.slashvision.im.R
import com.slashvision.im.ui.UImage
import com.slashvision.im.ui.UScreen

/**
 * author : lizhenxin
 *  date  : 2021/11/24
 *  desc  :
 */
const val ROUTE_IMAGE_PREVIEW = "_ROUTE_IMAGE_PREVIEW_"

/**
 * 图片预览页
 */
@ExperimentalComposeUiApi
@Composable
fun PageImagePreview(isNetImage: Boolean, path: String, navController: NavHostController) = UScreen(
    statusBarColor = colorResource(id = R.color.black)
) {
    Box(modifier = Modifier
        .fillMaxSize()
        .clickable { navController.navigateUp() }) {
        UImage(
            drawableId = R.drawable.ic_back,
            modifier = Modifier
                .padding(horizontal = 16.dp)
                .align(Alignment.TopStart),
            onClick = { navController.navigateUp() }
        )
        UImage(
            request = path,
            isLocal = !isNetImage,
            contentScale = ContentScale.FillWidth,
            canDrag = true,
            modifier = Modifier
                .fillMaxWidth()
                .padding(horizontal = 16.dp)
                .align(Alignment.Center)
        )
    }
}


const val ROUTE_VIDEO_PREVIEW = "_ROUTE_VIDEO_PREVIEW_"

/**
 * 视频预览页
 */
@Composable
fun PageVideoPreview() {

}